package org.example.sys.bean

import android.os.Parcel
import android.os.Parcelable
import androidx.databinding.BaseObservable
import com.google.gson.annotations.SerializedName


data class Book(
    var id: Int,
    var isbn: String?,
    var title: String?,
    var author: String?,
    @SerializedName("publication_year")
    var publicationYear: Int
) : Parcelable, BaseObservable() {

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(id)
        parcel.writeString(isbn)
        parcel.writeString(title)
        parcel.writeString(author)
        parcel.writeInt(publicationYear)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<Book> {
        override fun createFromParcel(parcel: Parcel): Book {
            return Book(
                parcel.readInt(),
                parcel.readString(),
                parcel.readString(),
                parcel.readString(),
                parcel.readInt()
            )
        }

        override fun newArray(size: Int): Array<Book?> {
            return arrayOfNulls(size)
        }
    }
}